<?php
// 模块函数文件
/**
 * json格式数据传输
 * @param int $code 业务状态码
 * @param string $message 信息提示
 * @param [] $data  数据
 * @return array
 */
use think\Db;
function ajax_return($code, $message, $data = [],$count=0)
{
    $data = array(
        'code' => $code,
        'msg' => $message,
        'data' => $data,
        'count' => $count,
    );
    exit(json_encode($data, JSON_UNESCAPED_UNICODE));
} 

function lvSettlementType($type){

   switch($type){
    case 0:
         return '手工结算';
    case 1:
         return '自动结算';
   }
}


/**
 *  订单投诉状态
 */
function  lvOrderComplainstatus($v)
{
    switch ($v) {
        case 0:
            return '新投诉';
        case 1:
            return '已解决';
        case 2:
            return '未解决';
    }
}
/**
 *  获取结算信息
 */
function  getSettlementType($v)
{
    switch ($v) {
        case 0:
            return '手工结算';
        case 1:
            return '自动结算'; 
    }
}
/**
 *  订单退款状态
 */
function  lvOrderRefundstatus($v)
{
    switch ($v) {
        case 0:
            return '申请中';
        case 1:
            return '已同意';
        case 2:
            return '已拒绝';
    }
}
 
/**
 * [LVVisitPrivilege 加载系统访问路径]
 * @Author   kendy
 * @DateTime 2019-11-18T15:55:13+0800
 */
function LVVisitPrivilege(){
     $listenUrl = cache('LV_LISTEN_URL'); 
     if(!$listenUrl){ 
         $list = model('admin/AuthRule')->getAllPrivileges(); 
         $listenUrl = [];
         foreach ($list as $v){
            if($v['name']=='')continue;
            $listenUrl[strtolower($v['name'])] =        
              [
                'url'=>$v['name'],
                'name'=>$v['title'],
                'isParent'=>true,
                'pid'=>$v['pid']
              ]; 
         }
         cache('LV_LISTEN_URL',$listenUrl);
     }
     return $listenUrl;
}
    function send_user_mes($receiveUserId,$title,$content){
            $mess['msg_type'] = 1;
            $mess['receive_user_id'] = $receiveUserId;
            $mess['msg_title'] = $title;
            $mess['create_time'] = date('Y-m-d H:i:s',time());
            $mess['msg_content'] =  $content;
            $mess['oid'] =  0;
            $mess['type'] =  0; 
            return Db::name('message')->insertGetId($mess); 
        }

